package com.le.tester.javaThink.fifth.chapter18_Str;

import java.math.BigInteger;
import java.util.Formatter;

/**
 * createTime：2021/8/11 11:47
 * description：formatter转换
 */
public class Conversion {
    public static void main(String[] args) {
        Formatter formatter = new Formatter(System.out);

        char u = 'a';
        System.out.println("u='a'");
        formatter.format("s:%s%n", u);

        formatter.format("c:%c%n", u);

        formatter.format("b:%b%n", u);

        formatter.format("h:%h%n", u);

        int v = 121;

        System.out.println("v=121");

        formatter.format("d:%d%n", v);
        formatter.format("c:%c%n", v);
        formatter.format("b:%b%n", v);
        formatter.format("s:%s%n", v);
        formatter.format("x:%x%n", v);
        formatter.format("h:%h%n", v);

        BigInteger w = new BigInteger("50000000000000");
        System.out.println("w = new BigInteger(\\\"50000000000000\\\")");
        formatter.format("d:%d%n", w);
        formatter.format("b:%b%n", w);
        formatter.format("s:%s%n", w);
        formatter.format("x:%x%n", w);
        formatter.format("h:%h%n", w);

        double x = 179.543;
        System.out.println("x=179.543");
        formatter.format("b:%b%n", x);
        formatter.format("s:%s%n", x);
        formatter.format("f:%f%n", x);
        formatter.format("e:%e%n", x);
        formatter.format("h:%h%n", x);

        Conversion y = new Conversion();
        System.out.println("y=new Conversion()");
        formatter.format("b:%b%n", y);
        formatter.format("s:%s%n", y);
        formatter.format("h:%h%n", y);

        boolean z = false;
        System.out.println("boolean z=false");
        formatter.format("b:%b%n", z);
        formatter.format("s:%s%n", z);
        formatter.format("h:%h%n", z);


    }
}
